#!/bin/sh

i=1
echo "please input the name of new group:"
read grpname
sudo groupadd $grpname
sudo mkdir -p /usr/myftp
sudo mkdir -p /usr/myftp/root
sudo mkdir -p /usr/myftp/root/download
sudo mkdir -p /usr/myftp/root/upload
sudo mkdir -p /usr/myftp/$grpname
echo "please input the number of $grpname specialty'students:"
read number

while [ $i -le $number ];
do
	if [ $i -lt 10 ]
	then
		username="stu0$i"
	else
		username="stu$i"
	fi
	sudo useradd -d /usr/myftp/$grpname/$username -g $grpname $username -m
	echo 123456|passwd --stdin $username
	sudo chown -R $username /usr/myftp/$grpname/$username
	sudo chgrp -R $grpname /usr/myftp/$grpname/$username
	i=$(($i+1))
done

exit 0
